import axios from "axios";
import { getCookie } from "./cookie";
import Cookies from "js-cookie"
const service = axios.create({
    baseURL: "https://api-hmzs.itheima.net/api",
    timeout: 5000
})
service.interceptors.request.use(config => {
    console.log(Cookies,"getcookie()");
    const token = getCookie();
    console.log(token);
    const KEY='token_key'
    console.log(Cookies.get(KEY));
    if (token) {
        config.headers.Authorization = token;
    }
    return config;
},
    error => {
        return Promise.reject(error)
    }
)
service.interceptors.response.use(
    response=>{
        return response.data
    },
    error=>{
        return Promise.reject(error)
    }
)
export default service